{% extends 'base.html' %}

{% block title %}编辑用户{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h2>编辑用户</h2>
            </div>
            <div class="card-body">
                <form method="post">
                    <div class="mb-3">
                        <label for="username" class="form-label">用户名</label>
                        <input type="text" class="form-control" id="username" value="{{ user.username }}" disabled>
                        <small class="text-muted">用户名不可修改</small>
                    </div>
                    <div class="mb-3">
                        <label for="full_name" class="form-label">姓名</label>
                        <input type="text" class="form-control" id="full_name" name="full_name" value="{{ user.full_name }}" required>
                    </div>
                    <div class="mb-3">
                        <label for="email" class="form-label">邮箱</label>
                        <input type="email" class="form-control" id="email" name="email" value="{{ user.email }}" required>
                    </div>
                    <div class="mb-3">
                        <label for="status" class="form-label">状态</label>
                        <select class="form-select" id="status" name="status" required>
                            <option value="active" {% if user.status == 'active' %}selected{% endif %}>在用</option>
                            <option value="inactive" {% if user.status == 'inactive' %}selected{% endif %}>停用</option>
                        </select>
                    </div>
                    <div class="mb-3">
                        <label for="role" class="form-label">角色</label>
                        <select class="form-select" id="role" name="role" required>
                            <option value="admin" {% if user.role == 'admin' %}selected{% endif %}>管理员</option>
                            <option value="business_user" {% if user.role == 'business_user' %}selected{% endif %}>业务用户</option>
                            <option value="department_manager" {% if user.role == 'department_manager' %}selected{% endif %}>部门经理</option>
                        </select>
                    </div>
                    <div class="d-flex justify-content-between">
                        <a href="{{ url_for('user.user_management') }}" class="btn btn-secondary">取消</a>
                        <button type="submit" class="btn btn-primary">更新用户</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}